package com.pet.controller;

import com.pet.pojo.Item;
import com.pet.pojo.User;
import com.pet.service.BuyService;
import com.pet.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/*  范刘士博  */
@CrossOrigin
@RestController
@RequestMapping("/buy")
public class BuyController {
    private String userName;
    private Integer itemId;
    @Autowired
    private BuyService buyService;
    @PostMapping("/setBuy")
    public void setBuy(String userName,Integer itemId){
        this.userName = userName;
        this.itemId = itemId;
    }
    @GetMapping("/getUser")
    public SysResult getUser(){
        User user = buyService.getUser(userName);
        return SysResult.success(user);
    }
    @GetMapping("/getItem")
    public SysResult getItem(){
        Item item = buyService.getItem(itemId);
        return SysResult.success(item);
    }
}
